SET SERVEROUTPUT ON
BEGIN
	--Creating the Program for running the stored Procedure users_free_space
  DBMS_SCHEDULER.CREATE_PROGRAM(
       program_name => 'DEMO_JOB_PROGRAM',
       program_type => 'STORED_PROCEDURE',
       program_action => 'users_free_space',
       enabled => FALSE,
       comments => 'Demo for job schedule.');
       dbms_scheduler.enable(name => 'DEMO_JOB_PROGRAM');
END;
/


BEGIN
	--Creating the Schedule for running the stored Procedure users_free_space at the regular period of time.
  DBMS_SCHEDULER.CREATE_SCHEDULE(
      schedule_name => 'DEMO_CREATE_SCHEDULED',
      start_date =>  SYSTIMESTAMP,
      repeat_interval => 'FREQ=HOURLY;byminute=0',
      comments => 'Runs every hour by minute to 0');

END;
/

BEGIN
	--Creating the Job for running the stored Procedure users_free_space at the regular period of time.
  DBMS_SCHEDULER.CREATE_JOB(
       job_name => 'SCHEDULEDDEMO',
       program_name =>'DEMO_JOB_PROGRAM',
       schedule_name =>'DEMO_CREATE_SCHEDULED',
       enabled => TRUE,
       comments => 'Runs every hour by minute to 0');

END;
/
